package com.demo.controller;

import com.demo.entity.SysRegion;
import com.demo.model.JsonMessage;
import com.demo.service.SysRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/user/region")
public class SysRegionController {
    @Autowired
    private SysRegionService sysRegionService;

    @PostMapping("findAllRegion")
    @ResponseBody
    public JsonMessage list()
    {
        JsonMessage message=new JsonMessage();
        List<SysRegion> list = sysRegionService.findByLevel(1);
        message.setData(list);
        return message;
    }

    @PostMapping("findRegionList")
    @ResponseBody
    public JsonMessage regionlist(String regionId)
    {
        JsonMessage message=new JsonMessage();
        List<SysRegion> list = sysRegionService.findRegionList(regionId);
        message.setData(list);
        return message;
    }
}
